//
//  HomeCell.m
//  NekaPrice
//
//  Created by yu on 2018/6/13.
//  Copyright © 2018年 ma c. All rights reserved.
//

#import "HomeCell.h"

@implementation HomeCell

+ (HomeCell *)homeCellWithTableView:(UITableView *)tableView andReuseIdentifier:(NSString *)reuseIdentifier {
    HomeCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    if (!cell) {
        cell = [[HomeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
        cell.backgroundColor = [UIColor clearColor];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        if ([reuseIdentifier isEqualToString:HomeCellID_Check]) {
            [self addSubview:self.checkLabel];
        }else if ([reuseIdentifier isEqualToString:HomeCellID_Money]) {
            [self addSubview:self.priceLabel];
        }else if ([reuseIdentifier isEqualToString:HomeCellID_TextDetail]) {
            [self addSubview:self.detalText];
        }else if ([reuseIdentifier isEqualToString:HomeCellID_ImgDetail]) {
            [self addSubview:self.detailImgView];
        }
        
        NSLog(@"%@", reuseIdentifier);
    }
    return self;
}


- (CheckLabel *)checkLabel {
    if (_checkLabel == nil) {
        _checkLabel = [[CheckLabel alloc] initWithFrame:CGRectMake(20, 5, 280, 40)];
    }
    return _checkLabel;
}

- (UILabel *)priceLabel {
    if (_priceLabel == nil) {
        _priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 5, 200, 40)];
        _priceLabel.font = [UIFont systemFontOfSize:16];
        _priceLabel.textColor = [UIColor yellowColor];
    }
    return _priceLabel;
}

- (UILabel *)detalText {
    if (_detalText == nil) {
        _detalText = [[UILabel alloc] initWithFrame:CGRectMake(20, 5, K_WIDTH - 40, 40)];
        _detalText.numberOfLines = 0;
        _detalText.font = [UIFont systemFontOfSize:14];
        _detalText.textColor = [UIColor whiteColor];
    }
    return _detalText;
}


- (UIImageView *)detailImgView {
    if (_detailImgView == nil) {
        if (kIsiPad) {
            _detailImgView = [[UIImageView alloc] initWithFrame:CGRectMake(15, 5, kContentView_WIDTH - 30, (K_WIDTH - 20) / 5.75)];
        }else {
            _detailImgView = [[UIImageView alloc] initWithFrame:CGRectMake(15, 5,  K_WIDTH - 30, (K_WIDTH - 20) / 5.75)];
        }
        
        _detailImgView.contentMode = UIViewContentModeScaleAspectFit;
    }
    return _detailImgView;
}

@end
                                                                       
